package jmu.cyxwcy.librarymanagement.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import jmu.cyxwcy.librarymanagement.mapper.BookDescriptionMapper;
import jmu.cyxwcy.librarymanagement.pojo.Book;
import jmu.cyxwcy.librarymanagement.pojo.BookDescription;
import jmu.cyxwcy.librarymanagement.service.BookDescriptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookDescriptionServiceImpl extends ServiceImpl<BookDescriptionMapper,BookDescription> implements BookDescriptionService {

    @Autowired
    private BookDescriptionMapper bookDescriptionMapper;

    public List<BookDescription> findByIsbnPartial(String isbnPartial) {
        QueryWrapper<BookDescription> queryWrapper = new QueryWrapper<>();
        queryWrapper.likeRight("isbn", isbnPartial);
        return list(queryWrapper);
    }

    @Override
    public IPage<BookDescription> join(IPage<BookDescription> page, MPJLambdaWrapper<BookDescription> queryWrapper) {
        return bookDescriptionMapper.selectJoinPage(page, BookDescription.class, queryWrapper);
    }
}
